<?php
if (!defined('IN_SCSM')) {
	die("Hacking attempt");
}

session_start();

?>
<script type="text/javascript">
	ddtabmenu.definemenu("menu", 4);
</script>

	<div id="content">
		<div class="page-contact">
		<?php
		if (isset($_REQUEST['email']))
		{
			if ($_POST['captcha'] != $_SESSION['captcha']) {
				echo "<div class=\"error\">Błędy kod z obrazka.</div>";
			} else {
				$email = $_REQUEST['email'];
				$name = $_REQUEST['name'];
				$subject = $_REQUEST['subject'];
				$message = $_REQUEST['message'];
				mail("wolfiq@gmail.com", $subject." (".$name.")", $message, "From:" . $email);
				echo "Dziękujemy za skorzystanie z naszego formularza.";
			}
		} else {
			echo "<form action=\"index.php?page=contact\" method=\"post\" onSubmit=\"return checkEmail();\">
			
				<table align=\"center\" cellpadding=\"5\" cellspacing=\"2\" border=\"0\">
					<tr>
						<td align=\"right\" valign=\"top\"><label>Imię i Nazwisko:</label></td>
						<td><input type=\"text\" name=\"name\" id=\"name\" class=\"styled2\"></td>
					</tr>
					<tr>
						<td align=\"right\" valign=\"top\"><label>Temat:</label></td>
						<td><input type=\"text\" name=\"subject\" id=\"subject\" class=\"styled2\"></td>
					</tr>
					<tr>
						<td align=\"right\" valign=\"top\"><label>email:</label></td>
						<td><input type=\"text\" name=\"email\" id=\"email\" class=\"styled2\"></td>
					</tr>
					<tr>
						<td align=\"right\" valign=\"top\"><label>Treść</label></td>
						<td><textarea name=\"message\" class=\"styled\" onfocus=\"this.value='';\">Wpisz swoją wiadomość</textarea></td>
					</tr>
					<tr>
						<td></td>
						<td><img src=\"images/img.php\" onClick=\"this.src='images/img.php?rand='+Math.random();\" title=\"Klinknij aby przeładować\"> Pamiętaj wielkość znaków ma znaczenie</td>
					</tr>
					<tr>
						<td align=\"right\" valign=\"top\"><label>Przepisz kod z obrazka</label></td>
						<td><input type=\"text\" name=\"captcha\" class=\"styled2\"></td>
					</tr>
					<tr>
						<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Wyślij\" name=\"submit\" class=\"button\"></td>
					</tr>
				</table>
			
			</form>";
		}
		?>
		</div>
		<hr>
	</div>